﻿<!--#include file="../base.asp"-->
<%if IsLogin then %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>保存作业</title>
</head>

<body>
<%
dim contid,sql,rs
contid=request.QueryString("contid")
if request.Form("startDate")<>"" and request.Form("stopDate")<>"" and request.Form("title")<>"" and request.Form("content")<>"" then

'添加信息
if contid="" then
if datediff("d",request.Form("startDate"),request.Form("stopDate"))>=0 then
sql="select * from [work]"
set rs=GetRecordset(sql,1)
rs.addnew
rs("title")=request.Form("title")
rs("content")=request.Form("content")
rs("postDate")=now()
rs("startDate")=request.Form("startDate")
rs("stopDate")=request.Form("stopDate")
if request.Form("ckbDiscuss")="on" then
    rs("discussAble")=1
else rs("discussAble")=0
end if
rs("userNum")=request.Cookies("username")
rs.update
showMsg "添加成功！",3,""
response.Redirect("comm/list_work.aspx")
rs.close
set rs=nothing
CLoseDataBase
else showMsg "结束日期不能在开始时间之前！",3,""
response.Write("<script language='javascript'>window.history.back();</script>")
end if
else

'修改信息
if datediff("d",request.Form("startDate"),request.Form("stopDate"))>=0 then
sql="select * from [work] where workID="&contid&" and [delete]=0"
set rs=GetRecordset(sql,1)
if not rs.eof and not rs.bof then
rs("title")=request.Form("title")
rs("content")=request.Form("content")
rs("postDate")=now()
rs("startDate")=request.Form("startDate")
rs("stopDate")=request.Form("stopDate")
if request.Form("ckbDiscuss")="on" then
    rs("discussAble")=1
else rs("discussAble")=0
end if
rs("userNum")=request.Cookies("username")
rs.update
showMsg "修改成功！",3,""
response.Redirect("comm/list_work.aspx")
rs.close
set rs=nothing
CLoseDataBase
else showMsg "警告：非法操作！",3,""
end if
else showMsg "结束日期不能在开始时间之前！",3,""
response.Write("<script language='javascript'>window.history.back();</script>")
end if
end if

else 
    showMsg "标题、内容或类别不能为空！<br />点击<a href='javascript:history.back()'>这里</a>返回",4,"" 
end if
%>
</body>
</html>
<%end if %>